//package com.joshua.spring.gateway.configuration;
//
//import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.http.HttpHeaders;
//import reactor.core.publisher.Mono;
//
//import java.util.Objects;
//
///**
// * projectName dragon-cloud
// * package com.joshua.spring.gateway.config
// * classname  RateLimiterBeanConfig
// * <p>
// * description
// * </p>
// *
// * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
// * @date 2020/9/16 16:59
// */
//@Configuration
//public class RateLimiterBeanConfiguration {
//    @Primary
//    @Bean(value = "ipKeyResolver")
//    public KeyResolver ipKeyResolver() {
//        return exchange -> Mono.just(Objects.requireNonNull(exchange.getRequest().getRemoteAddress()).getHostName());
//    }
//
//
//    @Bean(value = "tokenKeyResolver")
//    KeyResolver tokenKeyResolver() {
//        return exchange -> Mono.just(Objects.requireNonNull(exchange.getRequest().getHeaders().getFirst(HttpHeaders.AUTHORIZATION)));
//    }
//}
